package com.aba.cms.teacher;

public class Main {
    public static void main(String[] args) {
        // 初始化数据库表
        initDatabase();
        
        // 启动教师管理系统
        new TeacherController().manageTeachers();
    }

    // 初始化数据库表
    private static void initDatabase() {
        try (java.sql.Connection conn = DBConnection.getConnection();
             java.sql.Statement stmt = conn.createStatement()) {
            
            // 创建教师表
            String createTeachersTable = "CREATE TABLE IF NOT EXISTS teachers (" +
                                         "id INT PRIMARY KEY AUTO_INCREMENT," +
                                         "name VARCHAR(50) NOT NULL," +
                                         "department VARCHAR(50) NOT NULL," +
                                         "title VARCHAR(50) NOT NULL," +
                                         "phone VARCHAR(20)," +
                                         "email VARCHAR(50)" +
                                         ")";
            stmt.executeUpdate(createTeachersTable);
            
            // 创建课程表
            String createCoursesTable = "CREATE TABLE IF NOT EXISTS courses (" +
                                        "id INT PRIMARY KEY AUTO_INCREMENT," +
                                        "course_name VARCHAR(50) NOT NULL," +
                                        "course_code VARCHAR(20) NOT NULL," +
                                        "teacher_id INT NOT NULL," +
                                        "classroom VARCHAR(20) NOT NULL," +
                                        "day_of_week INT NOT NULL," +
                                        "start_time TIME NOT NULL," +
                                        "end_time TIME NOT NULL," +
                                        "FOREIGN KEY (teacher_id) REFERENCES teachers(id)" +
                                        ")";
            stmt.executeUpdate(createCoursesTable);
            
            System.out.println("数据库表初始化完成");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}    